package com.ycy;

import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;

public class ExcelDemo33 {

    /**
     * 按照 name 读取成 业务对象集合
     */
    public static void main(String[] args) throws FileNotFoundException {

        String filePath = "C:\\Users\\yincaiyong\\模板20240517a(包括导入及导出模板）\\导入模板\\居住区（村庄）台账导入模板.xlsx";
        filePath = "/Users/ycy/Desktop/居住区（村庄）台账导入模板.xlsx";
//        filePath = "C:\\Users\\yincaiyong\\Downloads\\A3-培训考试合格人员信息导入模板 (1).xlsx";
//        filePath = "C:\\Users\\yincaiyong\\Downloads\\A3-培训考试合格人员信息导入模板导入失败数据清单.xlsx";
//        filePath = "C:\\Users\\yincaiyong\\Downloads\\A3-培训考试合格人员信息导入模板导入失败数据清单 (1) - 副本.xlsx";

        filePath = "C:\\Users\\yincaiyong\\Desktop\\1724842003167_output - 副本.xlsx";

//        List<RaInfoV2ForVillageUploadForCommonUploadExcelByName> list = EasyExcel.read(new FileInputStream(filePath))
//                .head(RaInfoV2ForVillageUploadForCommonUploadExcelByName.class)
//                .sheet(0).headRowNumber(4)
//                .doReadSync();
//
//        System.out.println(JSONUtil.toJsonStr(list));

        /*
         console   ->
         [{"address":"1","entName":"4","entCodeGas":"6","entCode":"5","entCity":"2","entRegion":"3"}]
         */

//        List<RaInfoV2ForVillageUploadForCommonUploadExcelByName> list2 = EasyExcel.read(new FileInputStream(filePath))
//                .head(RaInfoV2ForVillageUploadForCommonUploadExcelByName.class)
//                .sheet(0).headRowNumber(3)
//                .doReadSync();
//
//        System.out.println(JSONUtil.toJsonStr(list2));

        /*
         console ->
         [{},
         {"address":"1","code":"11","checkConcentrationDeviceCount":"17","diaphragmGasFlowMeterCount":"21","latitude":24,
         "reportAndCloseDeviceCount":"18","remark":"25","gcBtCount":"16","iocGasFlowMeterCount":"22","resCount":"14",
         "icGasFlowMeterCount":"20","codeExtsys":"13","vaillageName":"10","streetOffice":"8","smartCloseDeviceCount":"19",
         "name":"9","alias":"12","longitude":23}]
         */
        System.out.println(filePath);
        GenericDataListener33 listener = new GenericDataListener33();
        EasyExcel.read(filePath, RaInfoV2ForVillageUploadForCommonUploadExcelByName.class, listener)
                .headRowNumber(2)
                .sheet().doRead();
        System.out.println(JSONUtil.toJsonStr(listener.getDataList()));

    }

}
